package com.ziyia.a4_5_2;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BookManager {

    public static class Book {
        public Integer id;
        public String title;
        public String desc;

        public Book(Integer id, String title, String desc) {
            this.id = id;
            this.title = title;
            this.desc = desc;
        }

        @Override
        public String toString() {
            return "Book{" +
                    "id=" + id +
                    ", title='" + title + '\'' +
                    ", desc='" + desc + '\'' +
                    '}';
        }
    }

    public static List<Book> ITEMS = new ArrayList<>();

    public static Map<Integer, Book> ITEM_MAP = new HashMap<>();

    static {
        addItem(new Book(1, "Git版本控制管理", "GIT"));
        addItem(new Book(2, "SpringBoot终极讲义", "SpringBoot"));
        addItem(new Book(3, "第一行Android代码", "Android"));
        addItem(new Book(4, "多线程并发的艺术", "Thread"));
    }

    private static void addItem(Book book) {
        ITEMS.add(book);
        ITEM_MAP.put(book.id, book);
    }
}
